package model;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import dao.BoxDao;

@FacesConverter(value="deptoConverter")
public class DeptoConverter implements Converter{
	
	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {					
		return new BoxDao().buscaDeptoBox(Integer.parseInt(arg2));
		
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		ClienteDepto cd = new ClienteDepto();
		cd = (ClienteDepto)arg2;
		cd= new BoxDao().buscaDeptoBox(cd.getId());
		return cd.getDescricao();
		
	}

}
